package logreport

import (
	"log"
	"time"
)

var instance = &LogReportHelper{}

type LogReportHelper struct {
	stopFlag chan struct{}
}

func GetInstance() *LogReportHelper {
	return instance
}

func (l *LogReportHelper) Start() {
	go func() {
		defer func() {
			if err := recover(); err != nil {
				log.Printf("log report helper err=%v\n", err)
			}
		}()

		for {
			select {
			case <-l.stopFlag:
				// TODO 优雅停机
			default:
				// 清理三天的日志

				time.Sleep(time.Minute)
			}
		}

	}()
}
func (l *LogReportHelper) Stop() {
	l.stopFlag <- struct{}{}
}
